

package dinamico.persistencia;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;


public class Persistencia
{
    static Persistencia instance = null;
    private EntityManager entityManager;
    private EntityManagerFactory entityManagerFactory;

    public Persistencia()
    {
        
        entityManagerFactory = Persistence.createEntityManagerFactory("UPS_UPSAM");
        entityManager = entityManagerFactory.createEntityManager();
        
    }

    public static Persistencia getInstance() throws Exception
    {
        if (instance == null)
        {
            instance = new Persistencia();
        }
        return instance;
    }

    public EntityManager getEntityManager()
    {
        return entityManager;
    }

}
